$(document).ready(function(){
		$(".button_con a" ).removeClass("l-btn-plain");

		//所属领域下拉框
		$('#comboxSearchfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage'+ '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
		    	comboxSearchSystemName.combobox({
                  disabled: false,
                  method:'get',
                  queryParams: {fieldId: record.id},
                  url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage'+ '?v=' + Math.random(),
                  valueField: 'id',
                  textField: 'name',
				  data:'',
      		    loadFilter: function(data){
      		    	var allCheck = {'id':'','name':'全部'};
      		    	data.content.unshift(allCheck);
      		    	return data.content;
      		    },
      		    onLoadSuccess:function(){
      		    	comboxSearchSystemName.combobox('setValue','');
      		    }
              }).load();
		    },
		    onLoadSuccess:function(){
		    	$('#cbSearch').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchSystemName').combobox({
          disabled: true,
          valueField: 'id',
          textField: 'name',
          editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
      });
		
		
		$("#datagrid").datagrid({
			url: BASE_URL_HISTORY_INTERFACE_CRUD + '/search/runningInterface' + '?v=' + Math.random(),
			method:'get',
			autoRowHeight:true,
			nowrap:false,
			singleSelect:true,
			striped:true,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						/*{field:'',width:10,checkbox:true},*/
						{field:'fieldName',title:'领域',width:100},
						{field:'fieldSystemName',title:'系统',width:100},
						{field:'interfaceName',title:'接口名称',width:100,align:'left'},
						{field:'scheduleName',title:'调度名',width:100,align:'left'},
						{field:'runBeginTime',title:'执行开始时间',width:100}
			      ]],
			pagination:true,
			onSelect:function(rowIndex,rowData){
				$("#toolbar_edit").linkbutton('enable');
				$("#toolbar_delete").linkbutton('enable');
			},
			loadFilter:function(data){
				//alert("inData:"+JSON.stringify(data));
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				
				param.sort = 'createTime,desc';
				 
				param.beginOfCreateTime = $('#txtBeginTime').datetimebox('getValue');
				param.endOfCreateTime = $('#txtEndTime').datetimebox('getValue');
				
				var fieldName = $('#comboxSearchfieldName').combobox('getText');
				if(fieldName !="全部"){
					param.fieldName = fieldName;
				}
				
				var fieldSystemName = $('#comboxSearchSystemName').combobox('getText');
				if(fieldSystemName !="全部"){
					param.fieldSystemName = fieldSystemName;
				}
				
				var interfaceName = $('#txtSearchInterfaceName').val();
				if(interfaceName !=""){
					param.interfaceName = interfaceName;
				}
				
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 

	
	//查看日志
	$('#tips_log').window({
		width:550,
		modal:true,
		minimizable:false,
		maximizable:false,
		collapsible:false
	});
	$('#tips_log').window('close');  //关闭窗口
	
	//导出日志
	$('#import_link').window({
		width:465,
		modal:true,
		minimizable:false,
		maximizable:false,
		collapsible:false
	});
	$('#import_link').window('close');  //关闭窗口
	
});
	//查询
	function search(){
		dataRetrieval('#txtBeginTime','#txtEndTime');
	}
	
	//查看日志操作
	function showLog()
	{
		var row = $('#datagrid').datagrid('getSelected');
				
		if(row == null){
			$.messager.alert("提示","<p>请选中要查看的记录!</p>","info");
		}else{
			
			var logField = row.logField;
			logField.replace("\r\n", "<br />");			
			$("#logTxt").html(logField);
			$('#tips_log').window('open'); 
		}
	}
	
	//导出日志操作
	function import_link()
	{
		$('#import_link').window('open'); 
	}
